package com.fileshare.web.dto.Vo;

import com.fileshare.web.entity.Article;
import com.fileshare.web.entity.Comment;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CommentVo {
    private Integer id;
    private String message;
    private String rereferenceType;
    private String referenceKey;
    private String status;
    private String toReference;
    private Integer likes;
    private Integer dislikes;
    private Date createAt;
    private Date updateAt;
    private String createBy;
    private String updateBy;
    private String commentSeq;
    public static CommentVo fromEntity(Comment comment) {
        CommentVo commentVo = new CommentVo();
        BeanUtils.copyProperties(comment, commentVo);
        return commentVo;
    }

    public static List<CommentVo> fromEntities(List<Comment> comments) {
        return comments.stream().map(CommentVo::fromEntity).collect(Collectors.toList());
    }
}
